
package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.soldier.dto.SoldierBasicInfoBSearcher;
import com.insigma.business.qrcode.soldier.dto.SoldierBasicInfoDTO;
import com.insigma.business.qrcode.soldier.entity.SoldierBasicInfoDO;
import com.insigma.business.qrcode.soldier.request.SoldierBasicInfoInsertRequest;
import com.insigma.business.qrcode.soldier.request.SoldierBasicInfoSearchRequest;
import com.insigma.business.qrcode.soldier.request.SoldierBasicInfoUpdateRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class SoldierBasicInfoProviderConverter extends AbstractConverter<SoldierBasicInfoDTO, SoldierBasicInfoDO> {

    private final static SoldierBasicInfoProviderConverter soldierBasicInfoConverter = new SoldierBasicInfoProviderConverter();

    private SoldierBasicInfoProviderConverter(){}

    
    public static SoldierBasicInfoBSearcher convertRequestSO2Searcher(final SoldierBasicInfoSearchRequest request){
        final SoldierBasicInfoBSearcher soldierBasicInfoBSearcher = new SoldierBasicInfoBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,soldierBasicInfoBSearcher);
        return soldierBasicInfoBSearcher;
    }

    
    public static SoldierBasicInfoDO convertRequestUO2DO(final SoldierBasicInfoUpdateRequest soldierBasicInfoUpdateRequest) {
        final SoldierBasicInfoDO soldierBasicInfoDO = new SoldierBasicInfoDO();
        BeanUtils.copyProperties(soldierBasicInfoUpdateRequest,soldierBasicInfoDO);
        
        return soldierBasicInfoDO;
    }

    
    public static SoldierBasicInfoDO convertRequestIO2DO(final SoldierBasicInfoInsertRequest soldierBasicInfoInsertRequest) {
        final SoldierBasicInfoDO soldierBasicInfoDO = new SoldierBasicInfoDO();
        BeanUtils.copyProperties(soldierBasicInfoInsertRequest,soldierBasicInfoDO);
        return soldierBasicInfoDO;
    }

    
    public static List<SoldierBasicInfoDTO> convertResponseDOList2DTOList(final List<SoldierBasicInfoDO> soldierBasicInfoDOList){
        return soldierBasicInfoConverter.convertGenericResponseDOList2DTOList(soldierBasicInfoDOList);
    }

    
    public static SoldierBasicInfoDTO convertResponseDO2DTO(final SoldierBasicInfoDO soldierBasicInfoDO){
        return soldierBasicInfoConverter.convertGenericResponseDO2DTO(soldierBasicInfoDO);
    }

    
    @Override
    protected SoldierBasicInfoDTO doConvertResponseDO2DTO(SoldierBasicInfoDO soldierBasicInfoDO) {
        final SoldierBasicInfoDTO soldierBasicInfoDTO = new SoldierBasicInfoDTO();
        try {
            BeanUtils.copyProperties(soldierBasicInfoDO, soldierBasicInfoDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return soldierBasicInfoDTO;
    }

}
